package logic

import (
	"activity_srv/activity"
	"activity_srv/internal/dao"
	"activity_srv/internal/svc"
	"context"
	"go.uber.org/zap"
	"smart-health-platforms/pkg"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetUserWithdrawInfoLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGetUserWithdrawInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserWithdrawInfoLogic {
	return &GetUserWithdrawInfoLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 提现
func (l *GetUserWithdrawInfoLogic) GetUserWithdrawInfo(in *activity.GetUserWithdrawInfoRequest) (*activity.GetUserWithdrawInfoResponse, error) {
	//业务逻辑
	withdraw, err := dao.GetUserWithdrawInfo(in)
	if err != nil {
		pkg.Error("获取提现信息失败", zap.Error(err))
		return nil, err
	}
	pkg.Info("获取提现信息成功", zap.Any("withdraw", withdraw))
	return &activity.GetUserWithdrawInfoResponse{
		Id:       int64(withdraw.Id),
		Withdraw: float32(withdraw.Withdraw),
	}, nil
}
